<template>
  <div>
    <md-form :mode="addressForm" class="form-box">
      <md-form-item type="text" placeholder="请输入您的姓名" v-model="addressForm.name" title="姓名" />
      <md-form-item type="text" placeholder="请输入您的手机号" v-model="addressForm.phone" title="手机号" />
      <md-form-item type="text" title="地址">
        <select>
          <option value="1">北京</option>
          <option value="1">上海</option>
          <option value="1">杭州</option>
        </select>
        <input type="text" placeholder="请选择地址" />
      </md-form-item>
      <md-form-item type="text" placeholder="请输入您的详细地址" v-model="addressForm.address" title="详细地址" />
    </md-form>
    <md-button type="primary" @click="submit" :round="false" class="add-address-btrn">提交</md-button>
  </div>
</template>

<script>
import storage from "@/utils/storage";
const addressForm = storage.getItem("addressForm");
export default {
  name: "EditAddress",
  data() {
    return {
      addressForm: {
        name: "",
        phone: "",
        location: {},
        address: ""
      }
    };
  },
  created() {
    this.$root.$on("selectLocation", location => {
      console.log(location, "地址");
      this.addressForm.location = location;
    });
  },
  activated() {
      const addressForm=storage.getItem('addressForm')
      if(addressForm){
          this.addressForm=addressForm
      }else{
          this.addressForm={
               name: "",
               phone: "",
               location: {},
               address: ""
          }
      }
  },
  methods: {
    submit() {
      console.log(this.addressForm);
    }
  }
};
</script>

<style lang="scss" scoped>
</style>